package view;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.ListModel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLayeredPane;
import javax.swing.JList;
import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import control.PesquisadorControle;

import model.Artigo;
import model.Pesquisador;

import java.awt.Choice;
import java.awt.ScrollPane;
import java.io.IOException;

public class Main extends JFrame {

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Main frame = new Main();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Main() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		getContentPane().setLayout(null);
		
		final DefaultListModel<Pesquisador> listModel = new DefaultListModel();
		
		final JList list = new JList();
		
		JButton btnNewButton = new JButton("Listar Artigos");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
					DefaultListModel listModel2 = PesquisadorControle.class.newInstance().pesquisadores();
					list.setModel(listModel2);
					
				} catch (InstantiationException | IllegalAccessException
						| ParserConfigurationException | SAXException
						| IOException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
				
				
			}
		});
		btnNewButton.setBounds(118, 210, 221, 23);
		getContentPane().add(btnNewButton);
		
		
		ScrollPane scrollPane = new ScrollPane();
		scrollPane.setBounds(37, 21, 367, 163);
		scrollPane.add(list);
		getContentPane().add(scrollPane);
	}
}
